// pages/zhufu/zhufu.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    relation: [],
    jieri: [],

    inputName:'',
    shenfenId:1,
    jieriId:1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    wx.request({
      url: app.globalData.url + 'get_wish_info',
      success:function(res){
        that.setData({
          relation: res.data.data.item_list,
          jieri: res.data.data.festival_list
        })
      }
    })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

  // 获取输入的名字
  inputChange: function (e) {
    this.setData({
      inputName: e.detail.value
    })
  },

  // 选择身份
  shenfenChange:function(e){
    var id = e.currentTarget.dataset.id
    this.setData({
      shenfenId:id
    })
  },

  // 选择节日
  jieriChange:function(e){
    var id = e.currentTarget.dataset.id
    var festival = e.currentTarget.dataset.festival
    this.setData({
      jieriId: id
    })
  },

  // 跳转生成页面
  onGotUserInfo:function(e){
    var userInfo = e.detail.userInfo
    if (userInfo){
      var name = this.data.inputName
      var shenfenId = this.data.shenfenId
      var jieriId = this.data.jieriId
      wx.navigateTo({
        url: 'result?relation=' + shenfenId + '&festival=' + jieriId + '&name=' + name + '&avatarUrl=' + userInfo.avatarUrl + '&nickName=' + userInfo.nickName,
      })
    }
  },

  
})